package me.sdevil507.drools.controller;

/**
 * @ClassName RuleController
 * @Description: TODO
 * @Author wgc
 * @Date 2021/10/27 11:08
 * @Version V1.0
 **/

import me.sdevil507.drools.model.AddressCheckResult;
import me.sdevil507.drools.model.Calculation;
import me.sdevil507.drools.model.CreditCardApplyInfo;
import me.sdevil507.drools.service.RuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rule")
public class RuleController {
    @Autowired
    private RuleService ruleService;

    @RequestMapping("/calculate")
    public Calculation calculate(double wage) {
        Calculation calculation = new Calculation();
        calculation.setWage(wage);
        calculation = ruleService.calculate(calculation);
        System.out.println(calculation);
        return calculation;
    }

    @RequestMapping("/creditCardApply")
    public CreditCardApplyInfo creditCardApply() {
        CreditCardApplyInfo creditCardApplyInfo1 = new CreditCardApplyInfo();
        creditCardApplyInfo1.setName("张三");
        creditCardApplyInfo1.setSex("男");
        creditCardApplyInfo1.setAge(30);
        creditCardApplyInfo1.setEducation(CreditCardApplyInfo.EDUCATION_4);
        creditCardApplyInfo1.setTelephone("13331077891");
        creditCardApplyInfo1.setMonthlyIncome(30000);
        creditCardApplyInfo1.setAddress("");
        creditCardApplyInfo1.setHasHouse(false);
        creditCardApplyInfo1.setHasCar(false);
        creditCardApplyInfo1.setHasCreditCardCount(0);
        creditCardApplyInfo1.setCheckResult(true);
        creditCardApplyInfo1.setQuota(20000);

        creditCardApplyInfo1 = ruleService.creditCardApply(creditCardApplyInfo1);
        return creditCardApplyInfo1;
    }


    @RequestMapping("/calculateAmount")
    public AddressCheckResult calculateAmount() {
        AddressCheckResult addressCheckResult = ruleService.calculateAmount();
        return addressCheckResult;
    }
}